﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestHarness
{
    public class TestCaseCollection : ICollection<TestCase>
    {
        private List<TestCase> testcases;

        public TestCaseCollection()
        {
            testcases = new List<TestCase>();
        }

        public void Add(TestCase item)
        {
            //throw new NotImplementedException();
            if (testcases.Contains(item))
            {
                throw new Exception("Duplited item...");
            }

            testcases.Add(item);
        }

        public void Clear()
        {
            //throw new NotImplementedException();
            testcases.Clear();
        }

        public bool Contains(TestCase item)
        {
            //throw new NotImplementedException();
            return testcases.Contains(item);
        }

        public void CopyTo(TestCase[] array, int arrayIndex)
        {
            //throw new NotImplementedException();
            int index = 0;
            while(index <array.Length && arrayIndex < testcases.Count)
            {
                array[index] = testcases[arrayIndex];
                index++;
                arrayIndex++;
            }
        }

        public int Count
        {
            get { return testcases.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public bool Remove(TestCase item)
        {
            testcases.Remove(item);
            return true;
        }

        public IEnumerator<TestCase> GetEnumerator()
        {
            return testcases.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return testcases.GetEnumerator();
        }
    }
}
